// 彩票数据解析工具
export function parseLotteryData(data) {
	const records = [];
	const lines = data.split('\n');

	for (const line of lines) {
		if (!line.trim()) continue;

		const parts = line.split(' ').filter(part => part !== '');
		if (parts.length < 7) continue; // 确保有足够的字段

		const issue = parts[0];
		const date = parts[1];
		// 提取号码 (第2到第6个字段)
		const numbers = parts.slice(2, 7).map(num => parseInt(num, 10));
		// 提取销售额 (第7个字段)
		const sales = parts.length > 7 ? parseInt(parts[7], 10) : undefined;
		// 提取注数 (第8个字段)
		const directBetCount = parts.length > 8 ? parseInt(parts[8], 10) : undefined;
		// 提取单注奖金 (第9个字段)
		const directBetPrize = parts.length > 9 ? parseInt(parts[9], 10) : undefined;
		// 提取特别号码 (第10个字段，如果有)
		const bonusNumber = parts.length > 10 ? parseInt(parts[10], 10) : undefined;

		records.push({
			issueNumber: issue,
			date: date,
			numbers: numbers,
			sales: sales,
			directBet: {
				count: directBetCount,
				prize: directBetPrize
			},
			bonusNumber: bonusNumber
		});
	}

	return records;
}

// 移除重复的默认导出，只保留命名导出